package com.sunlands.zlcx.usercenter.domain.log;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.io.Serializable;
import java.util.Date;

/**
 * @author anjl
 * @date 6:16 PM 2021/1/6
 * description: 用户在线记录，用socket的连接记录来标记用户在线时长
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity(name = "tz_user_online_log")
@DynamicUpdate
@DynamicInsert
public class UserOnlineLogDO implements Serializable {
    private static final long serialVersionUID = -5692772696570785488L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private Long userId;
    /**
     * 通道id
     */
    private Long channelId;
    /**
     * 上线时间
     */
    private Date onlineTime;
    /**
     * 下线时间
     */
    private Date offlineTime;
    /**
     * 在线时长，单位：秒
     */
    private Integer seconds;
    /**
     * 创建时间
     */
    @CreationTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    /**
     * 修改时间
     */
    @UpdateTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

}
